package com.axt.dbaudit.action.query;

import java.util.List;
import org.apache.struts2.json.annotations.JSON;
import com.axt.dbaudit.bean.query.QuerySessionBean;
import com.axt.dbaudit.model.query.Session;
import com.axt.dbaudit.model.query.SessionDetail;
import com.axt.dbaudit.model.query.SessionDetailHead;
import com.axt.soa.msg.types.*;

public class QuerySessionAction extends QueryBaseAction {
	private QuerySessionBean sessionBean = new QuerySessionBean();
	private List<Session> sessions = null;
	List<SessionDetail> sessionDetails = null;
	List<SessionDetailHead> sessionDetailHeads = null;
	
	@JSON(name="sessions")
	public List<Session> getSessions() {
		return sessions;
	}
	
	void setSessions(List<Session> sessions) {
		this.sessions = sessions;
	}
	
	@JSON(name="sessionDetails")
	public List<SessionDetail> getSessionDetails() {
		return sessionDetails;
	}
	
	void setSessionDetails(List<SessionDetail> sessionDetails){
		this.sessionDetails = sessionDetails;
	}
	
	@JSON(name="sessionheads")
	public List<SessionDetailHead> getSessionDetailHeads(){
		return sessionDetailHeads;
	}
	
	void setSessionHeads(List<SessionDetailHead> sessionDetailHeads){
		this.sessionDetailHeads = sessionDetailHeads;
	}
	
	@JSON(name="totalRows")
	public int getTotalRows() {
		return totalRows;
	}
	
	@JSON(name="queryProgress")
	public String getQueryProgress() {
		return queryProgress;
	}
	
	@JSON(name="queryDate")
	public String getQueryDate() {
		return queryDate;
	}
	
	@JSON(name="errcode")
	public int getErrcode() {
		return errcode;
	}
	
	@JSON(name="errinfo")
	public String getErrinfo() {
		return errinfo;
	}

	/* 会话查询 */
	public String querySessions() {
		
		/* 查询会话索引 */
		sessionBean.queryIndices(serverPath, filters, queryInResult, maxRowNum);
		
		setErrcode(sessionBean.getErrcode());
		setErrinfo(sessionBean.getErrinfo());
		
		return MsgParam.SUCCESS;

	}
	
	public String queryProcess(){
		/* 获取查询进度 */
		sessionBean.queryProcess(serverPath, filters);
		
		setQueryProgress(sessionBean.getQueryProgress());
		setQueryDate(sessionBean.getQueryDate());
		setErrcode(sessionBean.getErrcode());
		setErrinfo(sessionBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	public String querySessionData(){
		/* 查询结果 */
		sessionBean.querySessions(serverPath, filters);
		setSessions(sessionBean.getSessions());
		setErrcode(sessionBean.getErrcode());
		setErrinfo(sessionBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	public String querySessionDetail(){
		/* 查询会话详细信息  */
		sessionBean.querySessionDetail(serverPath, filters);
		setSessionDetails(sessionBean.getSessionDetails());
		setErrcode(sessionBean.getErrcode());
		setErrinfo(sessionBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
	
	public String querySessionHead(){
		/* 查询会话的公共头信息 */
		sessionBean.querySessionHead(serverPath, filters);
		setSessionHeads(sessionBean.getSessionDetailHeads());
		setErrcode(sessionBean.getErrcode());
		setErrinfo(sessionBean.getErrinfo());
		
		return MsgParam.SUCCESS;
	}
}
